import Vuex from 'vuex';
import Vue from 'vue'
Vue.use(Vuex)
const store = new Vuex.Store({
  state: {
    // 存储需要缓存的组件名
    caches: [],
    // 之前访问路由记录
    visitedRoutes: [],
		// 文件上传储存的数据
		pageParams: {
			testStandard: '',
			batchId: '',
			materialCode: '',
			recordCode: '',
			testId: ''
		},
		// 称重储存的数据
		weightParams: {
			}
  },
  mutations: {
    SET_CACHES(state, caches) {
      state.caches = caches;
    },
    ADD_CACHES(state, compName) {
      state.caches.push(compName);
    },
    REMOVE_CACHES(state, compName) {
      state.caches = state.caches.filter((item) => item !== compName);
    },
    SET_VISITED_ROUTES(state, visitedRoutes) {
      state.caches = visitedRoutes;
    },
    ADD_VISITED_ROUTES(state, path) {
      state.visitedRoutes.push(path);
    },
    REMOVE_VISITED_ROUTES(state, path) {
      state.visitedRoutes = state.visitedRoutes.filter((item) => item != path);
    },
		SET_PAGE_PARAMS(state, pageParams) {
			state.pageParams = pageParams;
		}
  }
})

export default store